package io.gitee.baicaixiaozhan.httpmessagewrapper;

import org.springframework.http.HttpStatus;


/**
 * DESC:
 *
 * @author baicaixiaozhan
 * @since v1.0.0
 */
public class SimpleResult implements UnifiedResult<Object> {

    private String code;

    private String status;

    private String message;

    private Object data;

    public SimpleResult() {}

    private SimpleResult(String code, String status, String message, Object data) {
        this.code = code;
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public String getStatus() {
        return status;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }

    @Override
    public UnifiedResult<Object> ok() {
        return new SimpleResult("200", String.valueOf(HttpStatus.OK.value()), HttpStatus.OK.getReasonPhrase(), null);
    }

    @Override
    public UnifiedResult<Object> ok(Object data) {
        return new SimpleResult("200", String.valueOf(HttpStatus.OK.value()), HttpStatus.OK.getReasonPhrase(), data);
    }

    @Override
    public UnifiedResult<Object> fail(String code, String status, String message) {
        return new SimpleResult(code, status, message, null);
    }

}
